********************************************************************************************************************************
***   Replication file for:                                                                                                  ***
***   Berbee, P., Braun, S. T. and Franke, R. (2024). Reversing Fortunes of German Regions, 1926-2019. JoEG				     ***
***   							                                                                                             ***
***   SCRIPT: 	_x2b_preparation_census_1907.do																				 ***	
***   PURPOSE: 	Reads in and prepares data from the 1895 occupation census												 	 ***
********************************************************************************************************************************


* Preamble (unnecessary when executing run.do)
run "$reversing/scripts/programs/_config.do"

************
* Code begins
************

*** Import data

import excel "$reversing/data/Berufszaehlung_1895.xlsx", sheet("Data") firstrow clear

rename C T_ID 
destring T_ID, replace
rename T_ID labor_market_id

**	Create employment outcomes from Berufszählung
gen total_empl=J // Employment in  1907

** Industrial employment share
gen empshare_ind_1895 = E / total_empl
label var empshare_ind_1895 "Employment share in industry (incl. mining and construction), 1895"

egen empshare_ind_1895_std=std(empshare_ind_1895)
label var empshare_ind_1895_std "Employment share in industry (incl. mining and construction), 1895 (standardized)"


*** Save data
keep labor_market_id empshare* 
sort labor_market_id

save "$reversing/processed/intermediate/occ_census1895.dta",replace

*** EOF
